var ws_protocol = 'ws'; // ws 或 wss
var server_ip = document.getElementById("server_ip").value;
var server_port = document.getElementById("server_port").value;
var ip = server_ip;
//var ip = '192.168.1.100';
var port = server_port;
var heartbeatTimeout = 5000; // 心跳超时时间，单位：毫秒
var reconnInterval = 1000; // 重连间隔时间，单位：毫秒

var binaryType = 'blob'; // 'blob' or 'arraybuffer';//arraybuffer是字节
var handler = new DemoHandler()

var tiows

function initWs () {
// var number = prompt("请输入自己的userid");
// var toUser = prompt("请输入要联系的userid");
//询问框
        var token = androidFun.getToken();
        var toUserid = document.getElementById("toUserid").value;
        var queryString = 'token='+token+"&toUserid="+toUserid;
        var param = null
        tiows = new tio.ws(ws_protocol, ip, port, queryString, param, handler, heartbeatTimeout, reconnInterval, binaryType)
        tiows.connect();
}
function send () {
  var msg = document.getElementById('textId');
  document.getElementById('contentId').innerHTML +='您自己说:'+ msg.value + '<br>'
  tiows.send(msg.value)
}

function clearMsg () {
  document.getElementById('contentId').innerHTML = ''
}

initWs()